﻿#region File Header
/***********************************************************************
 * Copyright © 2013 Beals Software
 * All Rights Reserved
************************************************************************
Author: Donald Beals
Date: February 4th, 2013
Description: TODO: Write a description of this file here.
****************************** Change Log ******************************
02.04.13 - Created initial file. (dbeals)
***********************************************************************/
#endregion

#region Using Statements
using System;

#endregion

namespace GameJolt
{
	/// <summary>
	/// 
	/// </summary>
	public static class Logging
	{
		#region Properties
		public static Action<string, string> EntryLogged
		{
			get;
			set;
		}

		public static bool IsEnabled
		{
			get
			{
				return EntryLogged != null;
			}
		}

		public static bool IgnoreInformation
		{
			get;
			set;
		}

		public static bool IgnoreWarnings
		{
			get;
			set;
		}

		public static bool IgnoreErrors
		{
			get;
			set;
		}
		#endregion

		#region Constructor
		static Logging()
		{
#if DEBUG
			EntryLogged = (type, text) => Console.WriteLine(string.Format("{0} - {1}", type, text));

			IgnoreInformation = false;
			IgnoreWarnings = false;
#else
			IgnoreInformation = true;
			IgnoreWarnings = true;
#endif
			IgnoreErrors = false;
		}
		#endregion

		#region Methods
		private static void LogEntry(string type, string text)
		{
			if(EntryLogged != null)
				EntryLogged(type, text);
		}

		public static void LogInformation(string text)
		{
			if(IgnoreInformation)
				return;
			LogEntry("Information", text);
		}

		public static void LogWarning(string text)
		{
			if(IgnoreWarnings)
				return;
			LogEntry("Warning", text);
		}

		public static void LogError(string text)
		{
			if(IgnoreErrors)
				return;
			LogEntry("Error", text);
		}
		#endregion
	}
}
